"use strict";
cc._RF.push(module, '6d4c2RLSRVHrrTJei2uQGIJ', 'mta-h5-analysis-2.0.15');
// scripts/mta-h5-analysis-2.0.15.js

"use strict";

var e = require;
var t = module;

function n(e) {
  return window.localStorage ? localStorage.getItem(e) : (e = document.cookie.match(new RegExp("(?:^|;\\s)" + e + "=(.*?)(?:;\\s|$)"))) ? e[1] : "";
}

function o(e, t, n) {
  if (window.localStorage) try {
    localStorage.setItem(e, t);
  } catch (e) {} else document.cookie = e + "=" + t + ";path=/;domain=" + i() + (n ? ";expires=" + n : "");
}

function i() {
  var e = window.location.host,
      t = e.split(".");
  2 < t.length && (e = ({
    "com.cn": 1,
    "js.cn": 1,
    "net.cn": 1,
    "gov.cn": 1,
    "com.hk": 1,
    "co.nz": 1
  }[t.slice(-2).join(".")] ? t.slice(-3) : t.slice(-2)).join("."));
  return e;
}

function a(e, t) {
  var n = {};

  if (void 0 === t) {
    var o = window.location,
        i = o.host,
        a = o.pathname,
        r = "";
    o.search && (r = o.search.substr(1));
    var s = o.hash;
  } else i = (o = t.match(/\w+:\/\/((?:[\w-]+\.)+\w+)(?::\d+)?(\/[^\?\\"'\|:<>]*)?(?:\?([^'"\\<>#]*))?(?:#(\w+))?/i) || [])[1], a = o[2], r = o[3], s = o[4];

  void 0 !== s && (s = s.replace(/"|'|<|>/gi, "M"));
  r && function () {
    for (var e = r.split("&"), t = 0, o = e.length; t < o; t++) {
      if (-1 != e[t].indexOf("=")) {
        var i = e[t].indexOf("="),
            a = e[t].slice(0, i);
        i = e[t].slice(i + 1);
        n[a] = i;
      }
    }
  }();

  r = function () {
    if ("undefined" == typeof r) return r;

    for (var t = r.split("&"), n = [], o = 0, i = t.length; o < i; o++) {
      if (-1 != t[o].indexOf("=")) {
        var a = t[o].indexOf("="),
            s = t[o].slice(0, a);
        a = t[o].slice(a + 1);
        e.ignoreParams && -1 != e.ignoreParams.indexOf(s) || n.push(s + "=" + a);
      }
    }

    return n.join("&");
  }();

  s && function () {
    for (var e = 0 == s.indexOf("#") ? s.substr(1).split("&") : s.split("&"), t = 0, n = e.length; t < n; t++) {
      if (-1 != e[t].indexOf("=")) {
        var o = e[t].indexOf("="),
            i = e[t].slice(0, o);
        o = e[t].slice(o + 1);
        if ("adtag" === i.toLowerCase()) break;
      }
    }
  }();
  return {
    host: i,
    path: a,
    search: r,
    hash: s,
    param: n,
    adtag: window.adTag
  };
}

function r(e) {
  var t = a(e),
      i = {
    dm: t.host,
    pvi: "",
    si: "",
    url: t.path,
    arg: encodeURIComponent(t.search || "").substr(0, 512),
    ty: 0
  };

  i.pvi = function () {
    if (e.userReport) {
      var t = n("pgv_uid");
      t && t == e.user.user_id || (i.ty = 1, o("pgv_uid", e.user.user_id, "Sun, 18 Jan 2038 00:00:00 GMT;"));
      t = e.user.user_id;
    } else (t = n("pgv_pvi")) || (i.ty = 1, o("pgv_pvi", t = s(), "Sun, 18 Jan 2038 00:00:00 GMT;"));

    return t;
  }();

  i.si = function () {
    var e = n("pgv_si");
    e || o("pgv_si", e = s("s"));
    return e;
  }();

  i.url = function () {
    var n = t.path;
    e.senseQuery && (n += t.search ? "?" + encodeURIComponent(t.search || "").substr(0, 512) : "");
    e.senseHash && (n += t.hash ? encodeURIComponent(t.hash) : "");
    return n;
  }();

  return i;
}

function s(e) {
  for (var t = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], n = 10; 1 < n; n--) {
    var o = Math.floor(10 * Math.random()),
        i = t[o];
    t[o] = t[n - 1];
    t[n - 1] = i;
  }

  for (n = o = 0; 5 > n; n++) {
    o = 10 * o + t[n];
  }

  return (e || "") + (o + "") + +new Date();
}

function c(e) {
  return {
    r2: e.sid
  };
}

function l(e) {
  var t = {};

  if (e) {
    var n,
        o = [];

    for (n in e) {
      e.hasOwnProperty(n) && o.push(encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
    }

    e = o.join(";");
    t.ext = e;
  }

  return t;
}

function d(e) {
  window.adTag = e;
  console.log("Tag:", window.adTag);
}

function h(e) {
  var t = a(e, document.referrer);
  e = a(e);
  return {
    rdm: t.host,
    rurl: t.path,
    rarg: encodeURIComponent(t.search || "").substr(0, 512),
    adt: window.adTag
  };
}

function u() {
  try {
    var e = navigator,
        t = screen || {
      width: "",
      height: "",
      colorDepth: ""
    },
        n = {
      scr: t.width + "x" + t.height,
      scl: t.colorDepth + "-bit",
      lg: (e.language || e.userLanguage).toLowerCase(),
      tz: new Date().getTimezoneOffset() / 60
    };
  } catch (e) {
    return {};
  }

  return n;
}

function p() {
  if (window.performance) {
    var e = window.performance.timing,
        t = {
      value: e.domainLookupEnd - e.domainLookupStart
    },
        n = {
      value: e.connectEnd - e.connectStart
    },
        o = {
      value: e.responseStart - (e.requestStart || e.responseStart + 1)
    },
        i = e.responseEnd - e.responseStart;
    e.domContentLoadedEventStart ? 0 > i && (i = 0) : i = -1;
    e = {
      domainLookupTime: t,
      connectTime: n,
      requestTime: o,
      resourcesLoadedTime: {
        value: i
      },
      domParsingTime: {
        value: e.domContentLoadedEventStart ? e.domInteractive - e.domLoading : -1
      },
      domContentLoadedTime: {
        value: e.domContentLoadedEventStart ? e.domContentLoadedEventStart - e.fetchStart : -1
      }
    };
  } else e = "";

  return e;
}

t.exports = {
  conf: {},
  version: "2.0.15",
  init: function init(e) {
    var t = {
      sid: 0,
      cid: 0,
      autoReport: 0,
      senseHash: 0,
      senseQuery: 0,
      userReport: 0,
      performanceMonitor: 0,
      ignoreParams: []
    };

    if (e) {
      for (var n in e) {
        e.hasOwnProperty(n) && t.hasOwnProperty(n) && (t[n] = e[n]);
      }

      e.hasOwnProperty("adTag") && d(e.adTag);
    }

    this.conf = t;
    this.conf.autoReport && this.pgv();
  },
  pgv: function pgv() {
    var e = this.conf,
        t = [],
        n = this.version;

    if (e.sid) {
      if (!e.userReport || e.user && e.user.user_id && !parseInt(e.user.user_id, 10) !== conf.user.user_id) {
        for (var o = 0, i = [r(e), h(e), c(e), u(), l({
          version: n
        }), {
          random: +new Date()
        }], a = i.length; o < a; o++) {
          for (var s in i[o]) {
            i[o].hasOwnProperty(s) && t.push(s + "=" + ("undefined" == typeof i[o][s] ? "" : i[o][s]));
          }
        }

        var d = function d(e) {
          e = ("https:" == document.location.protocol ? "https://pingtas.qq.com/webview" : "http://pingtcss.qq.com") + "/pingd?" + e.join("&").toLowerCase();
          var t = new Image();

          t.onload = t.onerror = t.onabort = function () {
            t = t.onload = t.onerror = t.onabort = null;
          };

          t.src = e;
        };

        d(t);
        e.performanceMonitor && (t = function t() {
          for (var t = p(), o = [], i = [], a = 0, s = [r(e), {
            r2: e.cid
          }, u(), {
            random: +new Date()
          }], c = s.length; a < c; a++) {
            for (var h in s[a]) {
              s[a].hasOwnProperty(h) && i.push(h + "=" + ("undefined" == typeof s[a][h] ? "" : s[a][h]));
            }
          }

          for (h in t) {
            t.hasOwnProperty(h) && ("domContentLoadedTime" == h ? i.push("r3=" + t[h].value) : o.push(t[h].value));
          }

          t = l({
            pfm: o.join("_"),
            version: n
          });
          i.push("ext=" + t.ext);
          d(i);
        }, "undefined" != typeof window.performance && "undefined" != typeof window.performance.timing && 0 != window.performance.timing.loadEventEnd ? t() : window.attachEvent ? window.attachEvent("onload", t) : window.addEventListener && window.addEventListener("load", t, !1));
      } else console.log("MTA H5分析错误提示：您选择了用户统计uv，请设置业务的user_id，需为int类型");
    } else console.log("MTA H5分析错误提示：您没有设置sid");
  },
  clickStat: function clickStat(e, t) {
    var n = this.conf,
        o = [],
        i = r(n),
        a = c(n);

    if (n.cid) {
      i.dm = "taclick";
      i.url = e;
      a.r2 = n.cid;

      a.r5 = function (e) {
        e = "undefined" == typeof e ? {} : e;
        var t,
            n = [];

        for (t in e) {
          e.hasOwnProperty(t) && n.push(t + "=" + encodeURIComponent(e[t]));
        }

        return n.join(";");
      }(t);

      var s = 0;

      for (i = (n = [i, h(n), a, u(), l({
        version: this.version
      }), {
        random: +new Date()
      }]).length; s < i; s++) {
        for (var d in n[s]) {
          n[s].hasOwnProperty(d) && o.push(d + "=" + ("undefined" == typeof n[s][d] ? "" : n[s][d]));
        }
      }

      o = ("https:" == document.location.protocol ? "https://pingtas.qq.com/webview" : "http://pingtcss.qq.com") + "/pingd?" + o.join("&");
      var p = new Image();

      p.onload = p.onerror = p.onabort = function () {
        p = p.onload = p.onerror = p.onabort = null;
      };

      p.src = o;
    } else console.log("MTA H5分析错误提示：您没有设置cid,请到管理台开通自定义事件并更新统计代码");
  },
  clickShare: function clickShare(e) {
    var t = this.conf,
        n = a(t),
        o = "undefined" == typeof (n = n.param.CKTAG || n.param.ckatg) ? [] : n.split(".");

    if (t.cid) {
      n = [];
      var i = r(t),
          s = c(t);
      i.dm = "taclick_share";
      i.url = "mtah5-share-" + e;
      s.r2 = t.cid;

      s.r5 = function (e) {
        var t = [];
        2 === e.length && "mtah5_share" == e[0] && t.push(e[0] + "=" + e[1]);
        return t.join(";");
      }(o);

      e = 0;

      for (i = (t = [i, h(t), s, u(), l({
        version: this.version
      }), {
        random: +new Date()
      }]).length; e < i; e++) {
        for (var d in t[e]) {
          t[e].hasOwnProperty(d) && n.push(d + "=" + ("undefined" == typeof t[e][d] ? "" : t[e][d]));
        }
      }

      d = ("https:" == document.location.protocol ? "https://pingtas.qq.com/webview" : "http://pingtcss.qq.com") + "/pingd?" + n.join("&");
      var p = new Image();

      p.onload = p.onerror = p.onabort = function () {
        p = p.onload = p.onerror = p.onabort = null;
      };

      p.src = d;
    } else console.log("MTA H5分析错误提示：您没有设置cid,请到管理台开通自定义事件并更新统计代码");
  }
};

cc._RF.pop();